// -----------------------------
// Author: 		Dhaenens Gert 
// Creation: 	9/17/2014 10:45:19 AM				
// -----------------------------

#ifndef _LuaStaticDataList_inl
#define _LuaStaticDataList_inl

namespace ObjectLua
{

	template<typename Class>
	LuaStaticDataList<Class>::LuaStaticDataList()
		: m_lpRoot(nullptr)
	{
	}

	template<typename Class>
	LuaStaticDataList<Class>::~LuaStaticDataList()
	{
		delete m_lpRoot;
	}

	template<typename Class>
	void LuaStaticDataList<Class>::addMember(BaseLuaStaticDataMember<Class>* lpMember)
	{
		if(m_lpRoot == nullptr)
		{
			m_lpRoot = lpMember;
			return;
		}

		BaseLuaStaticDataMember<Class>* lpLastObject = nullptr;
		BaseLuaStaticDataMember<Class>* lpObject = m_lpRoot;
		while(lpObject != nullptr)
		{
			lpLastObject = lpObject;
			lpObject = lpObject->m_lpNext;
		}
		lpLastObject->m_lpNext = lpMember;
	}
	template<typename Class>
	BaseLuaStaticDataMember<Class>* LuaStaticDataList<Class>::getMember(const char* name)
	{
		BaseLuaStaticDataMember<Class>* lpObject = m_lpRoot;
		while(lpObject != nullptr)
		{
			const char* lpName = lpObject->m_lpName;
			if(strcmp(lpName, name) == 0)
				return lpObject;
			lpObject = lpObject->m_lpNext;
		}
		return nullptr;
	}

}

#endif